package com.wanmait.schedule.controller;

import com.wanmait.schedule.entity.NoticeRecord;
import com.wanmait.schedule.service.NoticeRecordService;
import com.wanmait.schedule.util.AjaxResult;
import org.springframework.web.bind.annotation.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;
import java.util.List;

/**
 * <p>
 * 通知查看记录表 前端控制器
 * </p>
 *
 * @author wanmait
 * @since 2022-12-05
 */
@RestController
@RequestMapping("/web/noticeRecord")
public class NoticeRecordController {
    @Resource
    private NoticeRecordService noticeRecordService;

    //获取通知列表
    @PostMapping("list")
    public AjaxResult list( Integer id, Integer status){
        List<NoticeRecord> noticeRecordList = noticeRecordService.findNoticeById(id,status);
        return AjaxResult.success("成功",noticeRecordList);
    }

    //获取未读通知数量
    @PostMapping("noReader")
    public AjaxResult noReader(Integer id,Integer status){
        Integer noReader = noticeRecordService.noReader(id, status);
        return AjaxResult.success("成功",noReader);
    }

    //删除消息
    @GetMapping("delete/{id}")
    public AjaxResult delete(@PathVariable("id") Integer id){
        noticeRecordService.delete(id);
        return AjaxResult.success("成功");
    }
}
